
class Test:
  def __str__(self):
    return str(self.__dict__)

  def __init__(self,symbol, current_price, profit_per_hop, direction, bond, fund, defence_hands_arr, defence_interval_arr):
    # 品种自身属性
    self.symbol = symbol
    self.current_price = current_price
    self.profit_per_hop = profit_per_hop
    # 个人持仓情况
    self.direction =direction 
    self.bond = bond
    self.fund = fund
    self.lost_profit_every_percent = self.current_price * 0.01 * self.profit_per_hop

    # 主观计划
    self.defence_hands_arr = defence_hands_arr
    self.defence_interval_arr = defence_interval_arr

    # 计算属性
    self.hands = sum(self.defence_hands_arr)
    self.stages = len(self.defence_hands_arr)
    self.hands_spend = self.hands * self.bond
    self.losts_spend = None 
    self.total_spend = None 

    self.get_total_spend()


  def get_total_spend(self):
    losts = 0
    for n in range(0, self.stages):
      losts +=self.defence_hands_arr[n] * self.defence_interval_arr[n] * n

    self.losts_spend = losts * self.lost_profit_every_percent
    self.total_spend = self.hands_spend + self.losts_spend

豆油 = Test('豆油', 7662, 10, 1, 10000, 100000, 
  [1,1,2,3], 
  [2,4,2,4],
)

# 纯碱 = Test(7662, 10, 1, 10000, 100000, [1,1,2,3])


print(豆油)
